//
//  StatusCellBottomView.swift
//  微博三天
//
//  Created by jessica on 15/11/16.
//  Copyright © 2015年 jessica. All rights reserved.
//



//数线要用UIView创建,storyBoard只能创建最小是1的线,手动创建可以0.5
import UIKit
import SnapKit
class StatusCellBottomView: UIView {

    @objc private func retweetedBtnDidClcik(){
        
        let tempViewController = TempViewController()
        
        retweetedBtn.NavController()?.pushViewController(tempViewController, animated: true)
        
    }
    @objc private func composeBtnDidClcik(){
        
        let tempViewController = TempViewController()
        
        composeBtn.NavController()?.pushViewController(tempViewController, animated: true)
        
    }
    @objc private func likeBtnDidClcik(){
        
        let tempViewController = TempViewController()
        
        likeBtn.NavController()?.pushViewController(tempViewController, animated: true)
        
    }

    
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        //设置个颜色
        backgroundColor = UIColor(white: 0.95, alpha: 1)
       
                setupUI()
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
   //设置UI
    //MARK: 2.设置 UI
    
    private func setupUI() {
        //添加子视图
        addSubview(retweetedBtn)
        addSubview(composeBtn)
        addSubview(likeBtn)
        
        
        let w: CGFloat = 0.5
        let scale = 0.4
        //设置约束
        retweetedBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(snp_left)
            make.top.equalTo(snp_top)
            make.height.equalTo(snp_height)
        }
        
        let sepView1 = sepView()
        addSubview(sepView1)
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.height.equalTo(retweetedBtn.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
        }
        
        
        composeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.top.equalTo(snp_top)
            make.height.equalTo(snp_height)
            make.width.equalTo(retweetedBtn.snp_width)
        }
        
        let sepView2 = sepView()
        addSubview(sepView2)
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(composeBtn.snp_right)
            make.height.equalTo(retweetedBtn.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
        }
        
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(composeBtn.snp_right)
            make.top.equalTo(snp_top)
            make.right.equalTo(snp_right)
            make.height.equalTo(snp_height)
            make.width.equalTo(composeBtn.snp_width)
        }
        
        retweetedBtn.addTarget(self, action: "retweetedBtnDidClcik", forControlEvents: .TouchUpInside)
        composeBtn.addTarget(self, action: "composeBtnDidClcik", forControlEvents: .TouchUpInside)
        likeBtn.addTarget(self, action: "likeBtnDidClcik", forControlEvents: .TouchUpInside)
        

    }
    
    //添加按钮控件
    
    //创建分割线
    
    private func sepView()->UIView {
    
        let v = UIView()
        v.backgroundColor = UIColor.darkGrayColor()
return v
    
    
    
    }
    //MARK: 1. 懒加载所有子控件
    private lazy var retweetedBtn : UIButton = UIButton(title: "转发", color: UIColor.darkGrayColor(), backImage: nil, image: "timeline_icon_retweet", size: 14)
    private lazy var composeBtn: UIButton = UIButton(title: "评论", color: UIColor.darkGrayColor(), backImage: nil, image: "", size: 14)
    private lazy var likeBtn: UIButton = UIButton(title: "赞", color: UIColor.darkGrayColor(), backImage: nil, image: "timeline_icon_unlike", size: 14)


}

  